<?php

namespace common\services;

use common\helpers\RsaHelper;
use Yii;
use yii\web\Response;
use common\models\Homework;

class MaintainHomeworkService
{
    //维护作业信息
    public static function updateHomework()
    {
        Homework::updateAll(
            ['status' => 1],
            "status = 0 AND start_time <= '".date('Y-m-d H:i:s')."'"
        );
        Homework::updateAll(
            ['status' => 2],
            "status = 1 AND end_time <= '".date('Y-m-d H:i:s')."'"
        );
    }

    //维护作业结束状态
    public static function updateHomeworkStatus()
    {
        Homework::updateAll(
            ['status' => 3],
            "status = 2 AND not_submitted = 0 AND not_reviewed = 0"
        );
    }

}